package net.onceface.application.dto;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import net.onceface.application.assembler.ProductAssembler;
import net.onceface.application.assembler.ProductPictureAssembler;
import net.onceface.application.assembler.SpecAssembler;
import net.onceface.core.domain.Product;

public class ProductDTO implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2552994131342063356L;

	private int version;
	
	private Long id;
	
	private Date createDate;
	
	private Date abolishDate;
	
	private String name;
	
	private List<ProductPictureDTO> productPictureDTOs;
	
	private Integer level;
	
	private Integer sortOrder;
	
	private String sn;
	
	private double price;
	
	private Long catgoryId;
	
	private double originalPrice;
	
	private Integer specId;
	
	private String specName;
	
	private boolean sale;
	
	private int stock;
	
	private String picture;
	
	private Integer collection;
	
	private Integer totalSaleVolume;
	
	private Integer moonSaleVolume;
	
	private CategoryDTO category;
	
	private List<SpecDTO> SpecDTOs;
	
	/**
	 * 为商品列表定制的DTO
	 * **/
	public ProductDTO(Long id, String name, double price, double originalPrice, String specName, String picture, int stock){
		this.id = id;
		this.name = name;
		this.price = price;
		this.originalPrice = originalPrice;
		this.specName = specName;
		this.picture = picture;
		this.stock = stock;
	}
	
	public ProductDTO(Product product){
		this.clone(ProductAssembler.toDTO(product));
		this.setProductPictureDTOs(ProductPictureAssembler.toDTOs(product.getProductPicture()));
		this.setSpecDTOs(SpecAssembler.toDTOs(product.getSpec()));
	}

	public ProductDTO(){
		
	}

	private void clone(ProductDTO dto) {
		this.id = dto.id;
		this.version = dto.version;
		this.createDate = dto.createDate;
		this.abolishDate = dto.abolishDate;
		this.name = dto.name;
		this.level = dto.level;
		this.sortOrder = dto.sortOrder;
		this.sn = dto.sn;
		this.price = dto.price;
		this.catgoryId = dto.catgoryId;
		this.stock = dto.stock;
		this.picture = dto.picture;
		this.collection = dto.collection;
		this.totalSaleVolume = dto.totalSaleVolume;
		this.moonSaleVolume = dto.moonSaleVolume;
	}
	
	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public Long getId() {
		return id;
	}

	public List<SpecDTO> getSpecDTOs() {
		return SpecDTOs;
	}

	public void setSpecDTOs(List<SpecDTO> specDTOs) {
		SpecDTOs = specDTOs;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getAbolishDate() {
		return abolishDate;
	}

	public void setAbolishDate(Date abolishDate) {
		this.abolishDate = abolishDate;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public Integer getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(Integer sortOrder) {
		this.sortOrder = sortOrder;
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public Long getCatgoryId() {
		return catgoryId;
	}

	public void setCatgoryId(Long catgoryId) {
		this.catgoryId = catgoryId;
	}

	public double getOriginalPrice() {
		return originalPrice;
	}

	public void setOriginalPrice(double originalPrice) {
		this.originalPrice = originalPrice;
	}

	public Integer getSpecId() {
		return specId;
	}

	public void setSpecId(Integer specId) {
		this.specId = specId;
	}

	public List<ProductPictureDTO> getProductPictureDTOs() {
		return productPictureDTOs;
	}

	public void setProductPictureDTOs(List<ProductPictureDTO> productPictureDTOs) {
		this.productPictureDTOs = productPictureDTOs;
	}

	public String getSpecName() {
		return specName;
	}

	public void setSpecName(String specName) {
		this.specName = specName;
	}

	public boolean isSale() {
		return sale;
	}

	public void setSale(boolean sale) {
		this.sale = sale;
	}

	public int getStock() {
		return stock;
	}

	public void setStock(int stock) {
		this.stock = stock;
	}

	public String getPicture() {
		return picture;
	}

	public void setPicture(String picture) {
		this.picture = picture;
	}

	public Integer getCollection() {
		return collection;
	}

	public void setCollection(Integer collection) {
		this.collection = collection;
	}

	public Integer getTotalSaleVolume() {
		return totalSaleVolume;
	}

	public void setTotalSaleVolume(Integer totalSaleVolume) {
		this.totalSaleVolume = totalSaleVolume;
	}

	public Integer getMoonSaleVolume() {
		return moonSaleVolume;
	}

	public void setMoonSaleVolume(Integer moonSaleVolume) {
		this.moonSaleVolume = moonSaleVolume;
	}

	public CategoryDTO getCategory() {
		return category;
	}

	public void setCategory(CategoryDTO category) {
		this.category = category;
	}
}
